<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仪表盘 - SaaS平台管理系统</title>
    <!-- 引入Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- 引入Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
    <!-- 引入公共CSS -->
    <link href="./css/common.css" rel="stylesheet">
    <!-- 引入公共JS -->
    <script src="./js/common.js"></script>
    <!-- 仪表盘特定样式 -->
    <style>
        /* 统计卡片 */
        .stats-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            border: 1px solid #e2e8f0;
            transition: var(--transition);
        }

        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }

        .stat-card-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 1rem;
        }

        .stat-card-title {
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--secondary-color);
            margin: 0;
        }

        .stat-card-icon {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: #fff;
        }

        .stat-card-icon.primary {
            background: linear-gradient(135deg, var(--primary-color), #60a5fa);
        }

        .stat-card-icon.success {
            background: linear-gradient(135deg, var(--success-color), #34d399);
        }

        .stat-card-icon.warning {
            background: linear-gradient(135deg, var(--warning-color), #fbbf24);
        }

        .stat-card-icon.danger {
            background: linear-gradient(135deg, var(--danger-color), #f87171);
        }

        .stat-card-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark-bg);
            margin-bottom: 0.5rem;
        }

        .stat-card-change {
            display: flex;
            align-items: center;
            font-size: 0.875rem;
            font-weight: 500;
        }

        .stat-card-change.positive {
            color: var(--success-color);
        }

        .stat-card-change.negative {
            color: var(--danger-color);
        }

        .stat-card-change i {
            margin-right: 0.5rem;
        }

        /* 图表容器 */
        .charts-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
            gap: 2rem;
            margin-bottom: 2rem;
        }

        .chart-card {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            border: 1px solid #e2e8f0;
        }

        .chart-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--dark-bg);
            margin-bottom: 1.5rem;
        }

        .chart-wrapper {
            height: 300px;
        }

        /* 最近活动 */
        .recent-activities {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            border: 1px solid #e2e8f0;
        }

        .activity-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--dark-bg);
            margin-bottom: 1.5rem;
        }

        .activity-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        .activity-item {
            display: flex;
            gap: 1rem;
        }

        .activity-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary-color), #60a5fa);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            flex-shrink: 0;
        }

        .activity-content {
            flex: 1;
        }

        .activity-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 0.5rem;
        }

        .activity-name {
            font-weight: 600;
            color: var(--dark-bg);
        }

        .activity-time {
            font-size: 0.75rem;
            color: var(--secondary-color);
        }

        .activity-description {
            font-size: 0.875rem;
            color: var(--secondary-color);
        }

        /* 响应式设计 */
        @media (max-width: 1024px) {
            .charts-container {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .stats-cards {
                grid-template-columns: 1fr;
            }

            .chart-wrapper {
                height: 250px;
            }
        }
    </style>
</head>
<body>
    <!-- 加载动画 -->
    <div class="loader"></div>

    <div class="main-container">
        <!-- 侧边栏 -->
        <aside class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <div class="logo">
                    <div class="logo-icon">S</div>
                    <span class="logo-text">平台端系统</span>
                </div>
                <button class="sidebar-toggle" id="sidebarToggle">
                    <i class="fa fa-angle-left toggle-icon"></i>
                </button>
            </div>
            <nav class="sidebar-nav">
                <a href="index.html" class="nav-link active">
                    <i class="fa fa-dashboard nav-icon"></i>
                    <span class="nav-text">仪表盘</span>
                </a>
                <a href="users.html" class="nav-link">
                    <i class="fa fa-users nav-icon"></i>
                    <span class="nav-text">用户管理</span>
                </a>
                <a href="analytics.html" class="nav-link">
                    <i class="fa fa-bar-chart nav-icon"></i>
                    <span class="nav-text">数据分析</span>
                </a>
                <a href="tenant-settings.html" class="nav-link">
                    <i class="fa fa-building nav-icon"></i>
                    <span class="nav-text">租户设置</span>
                </a>
                <a href="contracts.html" class="nav-link">
                    <i class="fa fa-file-text-o nav-icon"></i>
                    <span class="nav-text">合同管理</span>
                </a>
                <a href="settings.html" class="nav-link">
                    <i class="fa fa-cog nav-icon"></i>
                    <span class="nav-text">系统设置</span>
                </a>
                <a href="notifications.html" class="nav-link">
                    <i class="fa fa-bell nav-icon"></i>
                    <span class="nav-text">通知中心</span>
                </a>
                <a href="reports.html" class="nav-link">
                    <i class="fa fa-file-text nav-icon"></i>
                    <span class="nav-text">报表管理</span>
                </a>
                <a href="orders.html" class="nav-link">
                    <i class="fa fa-shopping-cart nav-icon"></i>
                    <span class="nav-text">订单管理</span>
                </a>
                <a href="help.html" class="nav-link">
                    <i class="fa fa-question-circle nav-icon"></i>
                    <span class="nav-text">帮助中心</span>
                </a>
            </nav>
        </aside>

        <!-- 主内容 -->
        <main class="main-content" id="mainContent">
            <!-- 顶部导航栏 -->
            <nav class="top-nav">
                <div class="nav-left">
                    <button class="sidebar-toggle d-md-none" id="mobileSidebarToggle">
                        <i class="fa fa-bars"></i>
                    </button>
                    <div class="search-box">
                        <i class="fa fa-search"></i>
                        <input type="text" placeholder="搜索...">
                    </div>
                </div>
                <div class="nav-right">
                    <div class="notification-icon">
                        <i class="fa fa-bell"></i>
                        <span class="notification-badge">3</span>
                    </div>
                    <div class="user-info">
                        <div class="user-avatar">JD</div>
                        <div class="user-details">
                            <div class="user-name">John Doe</div>
                            <div class="user-role">管理员</div>
                        </div>
                        <i class="fa fa-chevron-down"></i>
                    </div>
                </div>
            </nav>

            <!-- 内容区域 -->
            <div class="content">
                <!-- 页面标题 -->
                <div class="page-title">
                    <h1>仪表盘</h1>
                </div>

                <!-- 统计卡片 -->
                <div class="stats-cards">
                    <div class="stat-card">
                        <div class="stat-card-header">
                            <h3 class="stat-card-title">总用户数</h3>
                            <div class="stat-card-icon primary">
                                <i class="fa fa-users"></i>
                            </div>
                        </div>
                        <div class="stat-card-value">12,542</div>
                        <div class="stat-card-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+12.5% 本月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-card-header">
                            <h3 class="stat-card-title">活跃用户</h3>
                            <div class="stat-card-icon success">
                                <i class="fa fa-line-chart"></i>
                            </div>
                        </div>
                        <div class="stat-card-value">8,921</div>
                        <div class="stat-card-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+8.3% 本月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-card-header">
                            <h3 class="stat-card-title">总收入</h3>
                            <div class="stat-card-icon warning">
                                <i class="fa fa-money"></i>
                            </div>
                        </div>
                        <div class="stat-card-value">¥128,542</div>
                        <div class="stat-card-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+15.7% 本月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-card-header">
                            <h3 class="stat-card-title">待处理订单</h3>
                            <div class="stat-card-icon danger">
                                <i class="fa fa-shopping-cart"></i>
                            </div>
                        </div>
                        <div class="stat-card-value">247</div>
                        <div class="stat-card-change negative">
                            <i class="fa fa-arrow-down"></i>
                            <span>-3.2% 本月</span>
                        </div>
                    </div>
                </div>

                <!-- 图表区域 -->
                <div class="charts-container">
                    <div class="chart-card">
                        <h3 class="chart-title">用户增长趋势</h3>
                        <div class="chart-wrapper">
                            <canvas id="growthChart"></canvas>
                        </div>
                    </div>

                    <div class="chart-card">
                        <h3 class="chart-title">收入分布</h3>
                        <div class="chart-wrapper">
                            <canvas id="revenueChart"></canvas>
                        </div>
                    </div>
                </div>

                <!-- 最近活动 -->
                <div class="recent-activities">
                    <h3 class="activity-title">最近活动</h3>
                    <div class="activity-list">
                        <div class="activity-item">
                            <div class="activity-avatar">JD</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">John Doe</span>
                                    <span class="activity-time">2分钟前</span>
                                </div>
                                <div class="activity-description">登录了系统</div>
                            </div>
                        </div>

                        <div class="activity-item">
                            <div class="activity-avatar">AL</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Alice Lee</span>
                                    <span class="activity-time">15分钟前</span>
                                </div>
                                <div class="activity-description">创建了新用户</div>
                            </div>
                        </div>

                        <div class="activity-item">
                            <div class="activity-avatar">BM</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Bob Martin</span>
                                    <span class="activity-time">1小时前</span>
                                </div>
                                <div class="activity-description">更新了系统设置</div>
                            </div>
                        </div>

                        <div class="activity-item">
                            <div class="activity-avatar">CS</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Carol Smith</span>
                                    <span class="activity-time">3小时前</span>
                                </div>
                                <div class="activity-description">导出了用户报表</div>
                            </div>
                        </div>

                        <div class="activity-item">
                            <div class="activity-avatar">DK</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">David Kim</span>
                                    <span class="activity-time">5小时前</span>
                                </div>
                                <div class="activity-description">处理了12个订单</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <!-- 引入Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- 图表初始化脚本 -->
    <script>
        // 页面加载完成后初始化图表
        document.addEventListener('DOMContentLoaded', function() {
            // 用户增长趋势图表
            const growthCtx = document.getElementById('growthChart').getContext('2d');
            new Chart(growthCtx, {
                type: 'line',
                data: {
                    labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
                    datasets: [{
                        label: '用户增长',
                        data: [8500, 9200, 9800, 10500, 11300, 12542],
                        borderColor: '#4f46e5',
                        backgroundColor: 'rgba(79, 70, 229, 0.1)',
                        tension: 0.4,
                        fill: true,
                        pointBackgroundColor: '#4f46e5',
                        pointBorderColor: '#fff',
                        pointBorderWidth: 2,
                        pointRadius: 5
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            display: false
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            }
                        },
                        x: {
                            grid: {
                                display: false
                            }
                        }
                    }
                }
            });

            // 收入分布图表
            const revenueCtx = document.getElementById('revenueChart').getContext('2d');
            new Chart(revenueCtx, {
                type: 'doughnut',
                data: {
                    labels: ['订阅收入', '广告收入', '服务费', '其他'],
                    datasets: [{
                        data: [65, 15, 12, 8],
                        backgroundColor: [
                            '#4f46e5',
                            '#10b981',
                            '#f59e0b',
                            '#ef4444'
                        ],
                        borderWidth: 0,
                        hoverOffset: 10
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom'
                        }
                    }
                }
            });
        });
    </script>
</body>
</html>